Skip to content

test_runner: show interrupted test on SIGINT#61676

Open
mcollina wants to merge 1 commit intonodejs:mainfrom
mcollina:test-runner-show-interrupted-test
Open

test_runner: show interrupted test on SIGINT#61676
mcollina wants to merge 1 commit intonodejs:mainfrom
mcollina:test-runner-show-interrupted-test

Conversation

@mcollina
Copy link
Member

@mcollina mcollina commented Feb 4, 2026

Summary

When the test runner process is killed with SIGINT (Ctrl+C), display which test was running at the time of interruption. This makes it easier to identify tests that hang or take too long.

Changes

  • Add test:interrupted event emitted when SIGINT is received
  • Add interrupted() method to TestsStream
  • Handle the event in both TAP and spec reporters
  • TAP outputs: # Interrupted while running: <test>
  • Spec outputs with yellow header and warning symbol
  • Use setImmediate to allow reporter stream to flush before exit

Behavior

  • With process isolation (default): shows the file path since the parent runner only knows about file-level tests
  • With --test-isolation=none: shows the actual test name and location

Example output (TAP)

TAP version 13
# Interrupted while running: never ending test at /path/to/test.js:6:1

Example output (spec)

Interrupted while running:
⚠ never ending test (test.js:6:1)

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Feb 4, 2026
When the test runner process is killed with SIGINT (Ctrl+C), display
which test was running at the time of interruption. This makes it
easier to identify tests that hang or take too long.

- Add `test:interrupted` event emitted when SIGINT is received
- Add `interrupted()` method to TestsStream
- Handle the event in both TAP and spec reporters
- TAP outputs: `# Interrupted while running: <test>`
- Spec outputs with yellow header and warning symbol
- Use setImmediate to allow reporter stream to flush before exit

With process isolation (default), shows the file path since the
parent runner only knows about file-level tests. With --test-isolation=none,
shows the actual test name.
@mcollina mcollina force-pushed the test-runner-show-interrupted-test branch from dbbd948 to ad00a26 Compare February 4, 2026 11:54
Copy link
Member

@JakobJingleheimer JakobJingleheimer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea/feature, and the initial implementation LGTM 🙂

@mcollina mcollina marked this pull request as ready for review February 8, 2026 08:38
@mcollina mcollina added request-ci Add this label to start a Jenkins CI on a PR. semver-minor PRs that contain new features and should be released in the next minor version. labels Feb 8, 2026
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 8, 2026
@nodejs-github-bot
Copy link
Collaborator

@codecov
Copy link

codecov bot commented Feb 8, 2026

Codecov Report

❌ Patch coverage is 11.76471% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.72%. Comparing base (f77a709) to head (ad00a26).
⚠️ Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/test_runner/harness.js 17.85% 23 Missing ⚠️
lib/internal/test_runner/reporter/spec.js 4.34% 22 Missing ⚠️
lib/internal/test_runner/reporter/tap.js 0.00% 10 Missing ⚠️
lib/internal/test_runner/tests_stream.js 28.57% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #61676      +/-   ##
==========================================
- Coverage   89.74%   89.72%   -0.03%     
==========================================
  Files         674      675       +1     
  Lines      204360   204592     +232     
  Branches    39265    39303      +38     
==========================================
+ Hits       183412   183560     +148     
- Misses      13251    13307      +56     
- Partials     7697     7725      +28     
Files with missing lines Coverage Δ
lib/internal/test_runner/tests_stream.js 87.29% <28.57%> (-2.37%) ⬇️
lib/internal/test_runner/reporter/tap.js 94.88% <0.00%> (-3.36%) ⬇️
lib/internal/test_runner/reporter/spec.js 81.69% <4.34%> (-14.95%) ⬇️
lib/internal/test_runner/harness.js 87.13% <17.85%> (-4.70%) ⬇️

... and 49 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

defined.
The corresponding execution ordered event is `'test:complete'`.

### Event: `'test:interrupted'`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Event: `'test:interrupted'`
### Event: `'test:interrupted'`
<!-- YAML
added: REPLACEME
-->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants